<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!-- pageNavigationTemplate begin -->
<!-- name="action" value="" -->
<!-- name="curIdx" value="0" -->
<!-- name="pageCount" value="10" -->
<!-- name="recordCount" value="100" -->
<script type="text/javascript">
    function pageNavigationTemplate_keydown(){
        if(event.keyCode==13){
           alert("user.action?pageIdx="+this.value);
           self.open("user.action?pageIdx="+this.value,"_self");
        }
    }
</script>

kinzhang:${parameters.recordCount/parameters.pageCount}
<%-- parameters:${parameters} --%>
<s:set name="pageNum" value="parameters.recordCount/parameters.pageCount" />
pageNum0:${pageNum}
<s:set name="pageNum" value="@java.lang.Math@ceil(#pageNum)"   />
pageNum1:${pageNum}
<s:set name="pageNum" value="#pageNum < 1 ? 1 : #pageNum" />
pageNum2:${pageNum}
<s:set name="pageNavDis" value="5" />
<s:set name="pageNavBegin" value="parameters.curIdx - 5 >= 0 ? parameters.curIdx-5 : 0" />
<s:set name="pageNavEnd" value="parameters.curIdx + 5" />
<s:set name="pageNavEnd" value="#pageNavEnd >= #pageNum ? (#pageNum - 1) : (parameters.curIdx + 5)" />
<s:set name="actionName" value="parameters.action" />
<s:set name="idxParamName" value="parameters.idxParamName" />
<s:set name="curIdx" value="parameters.curIdx" />

<%-- 
pageNum:${pageNum}
pageNavDis:${pageNavDis}
pageNavBegin:${pageNavBegin}
pageNavEnd:${pageNavEnd}
actionName:${actionName}
idxParamName:${idxParamName}
--%>

<%-- 
<!-- 通过property可以取出来 -->
parameters.action:<s:property value="parameters.action" /> 
<!-- url 取不出来 -->
url:<s:url value="parameters.action"></s:url>
<!-- url default 能取出来 -->
url default:<s:url><s:param name="pageIdx" value="parameters.curIdx" /></s:url>
--%>

<span class=ipagenav>
    <s:if test="parameters.curIdx==0">
        <span>首页</span>
        &nbsp;
        <span>前一页</span>
    </s:if>
    <s:else>
        <a href="<s:url><s:param name="pageIdx" value="0" /></s:url>">首页</a>
        <a href="<s:url><s:param name="pageIdx" value="parameters.curIdx-1" /></s:url>">前一页</a>
    </s:else>
    &nbsp;
    <s:bean name="org.apache.struts2.util.Counter" var="counter">
        <s:param name="first" value="#pageNavBegin" />
        <s:param name="last" value="#pageNavEnd" /> 
        <%--  first=${pageNavBegin}--%>
        <%-- last=${pageNavEnd} --%>
        <s:iterator>
        <%-- 
        ${curIdx} 
        ${ current-1 }
        --%>
            <s:if test="#curIdx==(current-1)">
                [${current}]
            </s:if>
            <s:else>
                <a href="<s:url><s:param name="pageIdx" value="current-1" /></s:url>"><s:property value="current" /></a>
            </s:else>
        </s:iterator>
    </s:bean>
    &nbsp;&nbsp;

    <s:if test="parameters.curIdx>=#pageNum">
        <span>后一页</span>
        &nbsp;
        <span>尾页</span>
    </s:if>
    <s:else>
        <a href="<s:url><s:param name="pageIdx" value="#curIdx-1" /></s:url>">后一页</a>
        &nbsp;
        <a href="<s:url><s:param name="pageIdx" value="#pageNum-1" /></s:url>" title="尾页">尾页</a>
    </s:else>

    &nbsp;&nbsp;&nbsp;跳到
    <input type='text' id='thepage' size='3' class="admTextSeven" onkeydown='pageNavigationTemplate_keydown()' />页
    &nbsp;&nbsp;&nbsp;共${parameters.recordCount}个${pageNum}页
</span>


<!-- pageNavigationTemplate end -->
